<?php
$id=0;
$judul="";
$permalink="";
$tema="";
$pemateri_id="";
$nama_pemateri="";
$ket_pemateri="";
$kitab="";
$hari="";
$tgl_mulai="";
$jam_mulai="";
$tgl_selesai="";
$jam_selesai="";
$ket_jam="";
$lokasi_id="";
$nama_lokasi="";
$ket_lokasi="";
$lat="";
$lng="";
$biaya="";
$jns_peserta_id="";
$kontak="";
$poster="";
$panitia="";
$jns_kajian_id=1;
$keterangan="";
$published="no";
$alamat="";
$jns_peserta="";
$kota="";
foreach($kajian->result_array() as $row){
	$id=$row['id'];
	$judul=$row['judul'];
	$permalink=$row['permalink'];
	$tema=$row['tema'];
	$pemateri_id=$row['pemateri_id'];
	$nama_pemateri=$row['nama_pemateri'];
	$ket_pemateri=$row['ket_pemateri'];
	$kitab=$row['kitab'];
	$hari=$row['hari'];
	$tgl_mulai=$row['tanggal_mulai'];
	$jam_mulai=$row['jam_mulai'];
	$tgl_selesai=$row['tanggal_selesai'];
	$jam_selesai=$row['jam_selesai'];
	$ket_jam=$row['ket_jam'];
	$lokasi_id=$row['lokasi_id'];
	$nama_lokasi=$row['nama_lokasi'];
	$ket_lokasi=$row['ket_lokasi'];
	$lat=$row['lat'];
	$lng=$row['lng'];
	$biaya=$row['biaya'];
	$jns_peserta_id=$row['jns_peserta_id'];
	$kontak=$row['kontak'];
	$jns_kajian_id=$row['jns_kajian_id'];
	$panitia=$row['panitia'];
	$poster=$row['poster'];
	$keterangan=$row['keterangan'];
	$published=$row['published'];
	$alamat=$row['alamat'];
	$jns_peserta=$row['jns_peserta'];
	$kota=$row['kota'];
}
?>
			<!-- BEGIN #main -->
			<section id="main">
				
				<section id="content" class="grid_1 alpha omega">
					<!-- for left space -->
				</section>
				
				<section id="content" class="grid_10 alpha omega">
					<article>
						<p id="breadcrumb"><a href="<?php echo base_url()?>">Home</a> <span>&gt;</span> <a href="<?php echo base_url().'kajian.html'?>">Kajian</a> <span>&gt;</span> <?php echo $judul?></p>
						
						<h1><?php echo $judul?></h1>
	
						<div class="social-buttons">
							<div class="addthis_toolbox addthis_default_style "  addthis:url="<?php echo base_url().'kajian/'.$permalink?>" addthis:title="Tentang Kami" addthis:description="">
								<a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
								<a class="addthis_button_tweet"></a>
								<a class="addthis_button_google_plusone" g:plusone:size="medium"></a>
								<a  href="http://www.addthis.com/bookmark.php?v=250&pubid=ra-4efd28c125922f8f" class="addthis_counter addthis_pill_style"></a>
							</div>
						</div>
						
						<div class="one_third">
							<?php if($poster != ''){?>
							<h3>Poster</h3>
							<?php } ?>
							<ul class="kajian">
								<?php if($poster != ''){?>
								<li>								
									<a href="<?php echo base_url()."images/poster/$poster"?>" class="fancybox" ><img src="<?php echo base_url()."images/poster/$poster"?>" width="100%" /></a>
								</li>
								<?php } ?>
								<li>
									<h4>Peta Lokasi</h4>
									<div id="map" style="height:300px;float:center;"></div>
								</li>
						</div>
						
						<div class="two_third last">
							<h3>Hadirilah Kajian dengan Tema :</h3>
							<h2>
								"<?php echo $tema?>"
							</h2>
							
							<ul class="kajian">
								<li>
									<h4>Pemateri :</h4>
									<p>
										<?php echo $nama_pemateri?>
										<br />
										<?php echo nl2br($ket_pemateri)?>
									</p>
								</li>
								<li>
									<h4>Kitab Rujukan :</h4>
									<p>
										<?php echo nl2br($kitab)?>
									</p>
								</li>
								<li>
									<h4>Waktu dan Tempat :</h4>
									<p>
										<?php 
										if($jns_kajian_id == 1){
											echo "Setiap hari ".get_day($hari);
										}else{
											echo get_day(date('N', strtotime($tgl_mulai))).", ".dateToIndo($tgl_mulai);
										}
										
										?>
										<br />
										Pukul <?php echo substr($jam_mulai,0,5)." - ".substr($jam_selesai,0,5)?> (Waktu Setempat)
									<p>
									<p>
										Di <?php echo $nama_lokasi?>
										<br />
										<?php echo $alamat?>
										<br />
										<?php echo nl2br($ket_lokasi)?>
										<br />
										<?php echo nl2br($kota)?>
									</p>
								</li>
								<li>
									<h4>Peserta Kajian :</h4>
									<p>
										<?php echo nl2br($jns_peserta)?>
									</p>
								</li>
								<li>
									<h4>Infaq :</h4>
									<p>
									<?php echo nl2br($biaya)?>	
									</p>
								</li>
								<li>
									<h4>Kontak Person :</h4>
									<p>
										<?php echo nl2br($kontak)?>
									</p>
								</li>
								<li>
									<h4>Penyelenggara :</h4>
									<p>
										<?php echo nl2br($panitia)?>
									</p>
								</li>
								<li>
									<h4>Keterangan Lain :</h4>
									<p>
										<?php echo nl2br($keterangan)?>
									</p>
								</li>
							</ul>
						</div>
					</article>
				</section>
			
				<section id="sidebar" class="grid_4 alpha omega" style="margin-top:36px">
					<h3 class="font-ad">Jadwal Kajian Lain</h3>

					<ul class="events">
					<?php

					$data = $kajian_add['data'];
					//echo '<pre>'.var_dump($data).'</pre>';
					$count=0;
					$break = false;
					for($day=0; $day<=30; $day++){
						$date =  date('Y-m-d',mktime(0, 0, 0, date("m")  , date("d")+$day, date("Y")));
						$dayofweek = date('N',mktime(0, 0, 0, date("m")  , date("d")+$day, date("Y")));
						
						if($break)
							break;
							
						if(isset($data[$dayofweek])){
							foreach($data[$dayofweek] as $row){
								$cek = true;
								
								if($count == 4){
									$break = true;
									break;
								}
								if($row['jns_kajian_id'] != 1 && $row['tanggal_mulai'] != $date)
									$cek = false;
								
								if($row['permalink'] == $permalink)
									$cek = false;
								
								if($cek){
									$count++;
							
					?>
					<li>
						<span class="item-date"><?php echo date('M',strtotime($date))?> <span><?php echo date('d',strtotime($date))?></span></span>
						<h4><a href="<?php echo base_url().'kajian/'.$row['permalink']?>.html"><?php echo $row['judul']?></a></h4>
						<p><em>Tema:</em><?php echo $row['tema']?></p>
						<p><em>Pemateri:</em><?php echo $row['nama_pemateri']?></p>
						<p><em>Waktu:</em><?php echo $row['jam_mulai']?></p>
						<p><em>Tempat:</em><?php echo $row['nama_lokasi'].', '.$row['kota']?></p>
					</li>
					<?php 
								}
							}
						}
					} 
					?>
				</ul>
				</section>
				<section class="cl"></section>
			
			</section>
			<!-- END #main -->

<script>			
$(document).ready(function(){
	  
	setTimeout(function(){

		$("#map").gmap3(
			{ action:'init',
				options:{
					center:[<?php echo $lat?>,<?php echo $lng?>],
					zoom: 15
				}
			},
			{ 
				action: 'addMarker',
				lat:<?php echo $lat?>,
				lng:<?php echo $lng?>,
				marker:{
					options:{
						draggable: false,
						animation: google.maps.Animation.DROP
					},
					events:{
						click: function(marker, event, data){
							var map = $(this).gmap3('get'),
							infowindow = $(this).gmap3({action:'get', name:'infowindow'});
							infowindow.open(map, marker);
						},
						dragend: function(marker){
							$(this).gmap3({
								action:'getAddress',
								latLng:marker.getPosition(),
								callback:function(results){
									$("#lat").val(marker.getPosition().lat());
									$("#lng").val(marker.getPosition().lng());
								}
							});
						}
					}
				},
			}
		);
		
	},1000);
});
</script>